package com.alphabet;

import java.util.Locale;

import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class AlphabetActivity extends Activity implements OnClickListener, TextToSpeech.OnInitListener 
{
	final char StartChar = 'А'; 
	final char EndChar = 'Я'; 
	char currentChar = StartChar;
	private TextView text;
	TextToSpeech tts;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        tts = new TextToSpeech(this, this);
        tts.setLanguage(new Locale("ru_RU"));

        text = (TextView) findViewById(R.id.text); 
        text.setOnClickListener(this);
        ShowCurrentLetter();
    }

	@Override
	public void onClick(View v) {
		NextLetter();
	}

	private void NextLetter() {
		if(++currentChar == EndChar)
			currentChar = StartChar;
		ShowCurrentLetter();
	}

	private void ShowCurrentLetter() {
		String currentLetter = new String()+currentChar;
		text.setText(currentLetter);
		tts.speak(currentLetter, TextToSpeech.QUEUE_ADD, null);
	}

	@Override
	public void onInit(int arg0) {
		
	}
}